﻿using System;
using System.Collections.Generic;

namespace Xam.Bilibili.Lib.Extensions
{
    public sealed class DictoryEx<T, T2>
    {
        private List<Tuple<T, T2>> Items { get; }
        public int Count
        {
            get
            {
                return Items == null ? 0 : Items.Count;
            }
        }
        public DictoryEx()
        {
            Items = new List<Tuple<T, T2>>();
        }
        public void Add(T t1, T2 t2)
        {
            Items.Add(new Tuple<T, T2>(t1, t2));
        }
        public void Remove(T t1)
        {
            Items.RemoveAll(x => x.Item1.Equals(t1));
        }
        public void Foreach(Action<Tuple<T, T2>> action)
        {
            Items.ForEach(action);
        }
        public void Clear()
        {
            Items.Clear();
        }
    }
}